<template>
  <div id="shop-info">
    <div class="logo">
      <div class="logo-img">
        <img src="~assets/img/tabbar/icon2.png" alt="" />
      </div>
      <span>{{ shop_info.name }}</span>
    </div>
    <div class="info">
      <div class="info-left">
        <div class="sales-num">
          <div class="num">{{ shop_info.sellsCount | salesNumFilter }}</div>
          <div>总销量</div>
        </div>
        <div class="goods-num">
          <div class="num">{{ shop_info.goodsCount }}</div>
          <div>全部宝贝</div>
        </div>
      </div>
      <div class="info-right">
        <div
          class="info-right-item"
          v-for="(item, index) in shop_info.score"
          :key="index"
        >
          <span>{{ item.name }}</span>
          <span class="num" :class="{ better: item.isBetter }">{{
            item.score
          }}</span>
          <span class="flag" :class="{ better: item.isBetter }">{{
            item.isBetter ? '高' : '低'
          }}</span>
        </div>
      </div>
    </div>
    <div class="enter-shop">
      <div class="btn">进入店铺</div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    shop_info: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  filters: {
    salesNumFilter(value) {
      if (!value) {
        return 0
      } else {
        return (value / 10000).toFixed(2) + '万'
      }
    },
  },
}
</script>

<style lang="less" scoped>
#shop-info {
  padding: 0 10px 10px 10px;
  border-bottom: 5px solid #eeeeee;
  .logo {
    height: 80px;
    display: flex;
    align-items: center;
    .logo-img {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      overflow: hidden;
      display: flex;
      justify-content: center;
      align-items: center;
      border: 1px solid #cccccc;
      img {
        width: 80%;
      }
      margin-right: 10px;
    }

    span {
    }
  }

  .info {
    display: flex;
    height: 80px;
    font-size: 12px;
    .info-left {
      flex: 1;
      display: flex;
      text-align: center;
      border-right: 1px solid #eeeeee;
      .num {
        font-weight: bold;
        font-size: 14px;
      }
      .sales-num {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        div:nth-child(1) {
          // height: 30px;
          margin-bottom: 10px;
        }
      }

      .goods-num {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        div:nth-child(1) {
          // height: 30px;
          margin-bottom: 10px;
        }
      }
    }

    .info-right {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      align-items: center;
      .info-right-item {
        span {
          margin-left: 10px;
        }
        .num {
          color: green;
          &.better {
            color: @base-color;
          }
        }
        .flag {
          background-color: green;
          color: #ffffff;
          padding: 1px 2px;
          &.better {
            background-color: @base-color;
          }
        }
      }
    }
  }

  .enter-shop {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    .btn {
      margin-top: 20px;
      width: 40%;
      height: 30px;
      background-color: #f0f4fa;
      text-align: center;
      line-height: 30px;
      border-radius: 5px;
    }
  }
}
</style>
